var uuid = require('node-uuid');
const tableConfig={
    sqltext:{
        insert:{
            sql:data=>`INSERT INTO sys_dept(
                        dept_id,dept_name,dept_parent_id,dept_level,dept_seq,dept_remark
                        ) VALUES(
                        '${uuid.v1()}',{dept_name},{dept_parent_id},{dept_level},{dept_seq},{dept_remark})`
        },
        getById:{
            sql:data=>`select * from sys_dept where  dept_id={dept_id}`
        }
    },
    Constraints:[
        {name:"dept_id",isNull:false,isTrim:true},
        {
            name:"dept_name",
            isNull:false,
            isTrim:true,
            fun:(t)=>{
                if(t.length>20){
                    return {
                        type: false,
                        msg: "名称过长"
                    }
                }else{
                    return {
                        type:true
                    }
                }
            }
        },
        {name:"dept_parent_id",isNull:true,isTrim:true},
        {
            name:"dept_level",
            isNull:true,
            isTrim:true,
            expression:{
                text:/^[+]{0,1}(\d+)$/,
                msg:"内容需要是数字"
            }
        },
        {
            name:"dept_seq",
            isNull:false,
            isTrim:true,
            expression:{
                text:/^[+]{0,1}(\d+)$/,
                msg:"内容需要是数字"
            }
        },
        {name:"dept_remark",isNull:true,isTrim:false},
    ]

}
module.exports = tableConfig;